jQuery(document).ready(function(e$) { jQuery(".fbShare").on("click", function() { socialShare("fb"); }); jQuery(".twShare").on("click", function() { socialShare("tw"); }); function socialShare(type) { var post_title = jQuery('html').filter('title').text(); if (type == "fb") { window.open( "https://www.facebook.com/sharer/sharer.php?u=" + window.location.href, "sharer", "top=" + 200 + ",left=" + 200 + ",toolbar=0,status=0,width=" + 400 + ",height=" + 400 ); } else if (type == "tw") { URLtoShare = "https://twitter.com/intent/tweet?url=" + window.location.href + "&via=empire_living" + "&text=" + encodeURIComponent(post_title); //console.log(URLtoShare); window.open( URLtoShare, "sharer", "top=" + 200 + ",left=" + 200 + ",toolbar=0,status=0,width=" + 600 + ",height=" + 350 ); } } if(jQuery(".relatedBlogs").length > 0){ jQuery(".relatedBlogs") .not(".slick-initialized") .slick({ slidesToShow: 3, slidesToScroll: 1, infinite: false, dots: true, arrows: true, swipeToSlide: true, prevArrow: '
', nextArrow: '', slide: ".itemMosaic", responsive: [ { breakpoint: 1400, settings: { arrows:false, slidesToShow: 3 } }, { breakpoint: 992, settings: { arrows:false, slidesToShow: 1.7 } }, { breakpoint: 768, settings: { arrows:false, slidesToShow: 1.2 } } ] }); } jQuery(".read-more-wrapper .read-more a, .read-more-wrapper .read-less a").on("click", function(event) { event.preventDefault() jQuery(this).closest('.read-more-wrapper').toggleClass('open'); }); if(jQuery(".read-more-wrapper").length > 0){ jQuery(".read-more-wrapper").removeClass('open'); } }); function setMaxWidthByPosition(element, container) { const elementRect = element.getBoundingClientRect(); const containerRect = container.getBoundingClientRect(); // Calculate available space to the right of the element const availableWidth = elementRect.right - containerRect.left ; // Set max-width, ensuring it's not negative element.style.maxWidth = Math.max(0, availableWidth) + 'px'; } function setTopByPosition(element, container) { const containerRect = container.getBoundingClientRect(); const elementRect = element.getBoundingClientRect(); const top = containerRect.bottom - elementRect.top; console.log(containerRect, elementRect); // Set max-width, ensuring it's not negative element.style.top = Math.max(0, top) + 'px'; } const elements = document.querySelectorAll('.mega-container .jet-mega-menu-mega-container'); const elementsDropdown = document.querySelectorAll('.mmDropdown .jet-mega-menu-sub-menu'); const mmContainer = document.querySelector('#menuMegaContainer>.e-con-inner>.elementor-element'); document.addEventListener("DOMContentLoaded", () => { elements.forEach((element) => { setMaxWidthByPosition(element, mmContainer); }); }); // Call the function after the DOM is fully loaded window.addEventListener('load', () => { }); // Re-calculate and set max-width on window resize (optional) window.addEventListener('resize', () => { elements.forEach((element) => { setMaxWidthByPosition(element, mmContainer); }); });